home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / hash / shs.1 < prev    next >
Encoding:
Text File  |  1994-03-25  |  8.5 KB  |  320 lines  |  [TEXT/R*ch]

  1. .\" @(#)shs.1    10.1 3/25/94 08:03:58
  2. .\"
  3. .\" This man page was written by:
  4. .\"
  5. .\"     Landon Curt Noll  (chongo@toad.com)    chongo <was here> /\../\
  6. .\"
  7. .\" This man page has been placed in the public domain.  Please do not 
  8. .\" copyright this man page.
  9. .\"
  10. .\" LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH  REGARD  TO
  11. .\" THIS  SOFTWARE,  INCLUDING  ALL IMPLIED WARRANTIES OF MER-
  12. .\" CHANTABILITY AND FITNESS.  IN NO EVENT SHALL  LANDON  CURT
  13. .\" NOLL  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  14. .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM  LOSS  OF
  15. .\" USE,  DATA  OR  PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  16. .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR  IN
  17. .\" CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. .\"
  19. .\" See shsdrvr.c for version and modification history.
  20. .\"
  21. .TH SHS 1  LOCAL
  22. .SH NAME
  23. shs \- Secure Hash Standard
  24. .SH SYNOPSIS
  25. .BR shs \ [
  26. .BR \-cdhiqtx \ ][
  27. .BR \-p prefix\ ][
  28. .BR \-P prfile\ ][
  29. .BR \-s str\ ]
  30. file\ ...
  31. .SH DESCRIPTION
  32. The
  33. .B shs
  34. utility implements the Secure Hash Algorithm (\fISHA\fP).
  35. It produces 160-bit Secure Hash Digests of files, strings or data 
  36. read on stdin.
  37. If no
  38. .B file
  39. is given, and
  40. no string is to be digested (\fB\-s\fP)
  41. then stdin will be digested.
  42. By default, a digests are printed as 40 hex characters without a leading 
  43. .IR 0x .
  44. .PP
  45. The Secure Hash Standard (\fISHS\fP) is a United States
  46. Government approved standard (FIPS Pub 180) for secure hashing.
  47. The 
  48. .I SHS
  49. is designed to work with the Digital Signature Standard (\fIDSS\fP).
  50. The Secure Hash Algorithm (\fISHA\fP) 
  51. specified in this standard is
  52. necessary to ensure the security of the Digital Signature Standard. 
  53. When a message of length < 2^64 bits is input, the 
  54. .I SHA 
  55. produces a 160-bit representation of the message called the message digest. 
  56. The message digest is used during generation of a signature for the message.  
  57. The
  58. .I SHA 
  59. is designed to have the following properties: it is
  60. computationally infeasible to recover a message corresponding to a
  61. given message digest, or to find two different messages which
  62. produce the same message digest.
  63. .PP
  64. If a 
  65. .B str 
  66. (string) argument is given, then the digest for 
  67. .BR str ,
  68. followed by a space, followed by
  69. .B str 
  70. enclosed double quotes is written to stdout.
  71. Any
  72. .B file
  73. arguments are ignored.
  74. .PP
  75. If one or more
  76. .B file
  77. if given, a separate digest if produced for each file.
  78. By default, 
  79. .B file 
  80. digests are followed by a space and the filename.
  81. .PP
  82. If no 
  83. .B str
  84. or
  85. .B file
  86. arguments are given, then a digest of stdin is written to stdout.
  87. .PP
  88. .TP
  89. .B \-c
  90. Print C style hex digests with a leading \fI0x\fP.
  91. .TP
  92. .B \-d
  93. Compute dual digests.
  94. .sp
  95. Data is divided into two streams and digested separately.
  96. Each successive octet is assigned an index starting with 0.
  97. The even stream consists of octets with even indices.
  98. The odd stream consists of octets with odd indices.
  99. The even stream digest, followed by a space, followed by
  100. the odd stream digest is written to stdout.
  101. .TP
  102. .B \-h
  103. Print a help and usage message.
  104. .TP
  105. .B \-i
  106. Compute inode digests of files.
  107. .sp
  108. Prepend the filename and various inode information to the file data 
  109. being digested.
  110. The inode information prepended includes information
  111. such as the device (\fIst_dev\fP), 
  112. inode number (\fIst_ino\fP), 
  113. mode (\fIst_mode\fP), 
  114. link count (\fIst_nlink\fP), 
  115. uid (\fIst_uid\fP), 
  116. gid (\fIst_gid\fP), 
  117. size (\fIst_size\fP),
  118. modification time (\fIst_mtime\fP) and
  119. change time (\fIst_ctime\fP).
  120. The prepended data is padded with zeros to make it a multiple of 64
  121. bytes long.
  122. Both a
  123. .BR stat (2)
  124. and a
  125. .BR lstat (2)
  126. information are both used.
  127. .sp
  128. The \fB\-i\fP flag allows one to include various inode information in
  129. the digest.  
  130. This option is useful in detecting file tampering.
  131. For example, the following will produce different digests:
  132. .sp
  133. .in +0.5i
  134. .nf
  135. shs \-i /tmp/chongo
  136. cp /tmp/chongo /tmp/was_here
  137. \^... misc funny business ...
  138. cp /tmp/was_here /tmp/chongo
  139. shs \-i /tmp/chongo
  140. .fi
  141. .in -0.5i
  142. .sp
  143. Note that a \fB\-i\fP digest is not portable to other systems.
  144. This is because inode information will likely change as the
  145. contents of a file are copied from machine to machine.
  146. .sp
  147. To mark a \fB\-i\fP digest as a special value, \fI.0\fP is 
  148. prepended onto the digest output.
  149. .sp
  150. One may only compute inode digests of files.
  151. Use of
  152. .B \-i
  153. disables reading from stdin.
  154. The
  155. .B \-i
  156. flag is not compatible with
  157. .BR \-s .
  158. .TP
  159. .BI \-p prefix
  160. .TP
  161. .BI \-P prfile
  162. Insert a prefix into the data to be digested.
  163. .sp
  164. By using \fB\-p\fP\fIprefix\fP, one may prepend any set of data with a
  165. string.  
  166. The digest produced is equivalent to digest that is
  167. produced with the string pretended to the data.  
  168. Thus the following two commands produce the same digest:
  169. .sp
  170. .in +0.5i
  171. .nf
  172. shs \-p curds \-s whey
  173. shs \-s curdswhey
  174. .fi
  175. .in -0.5i
  176. .sp
  177. By use of the \fB\-P\fP\fIprfile\fP interface, one may prepend using
  178. up to the 32k of a file.  
  179. This interface allows one to prepend using binary data.  
  180. The following produces the same digest:
  181. .sp
  182. .in +0.5i
  183. .nf
  184. shs \-P /usr/bin/awk /bin/ls
  185. dd if=/usr/bin/awk of=/tmp/foo bs=32k count=1
  186. cat /tmp/foo /bin/ls > /tmp/ls
  187. shs /tmp/ls
  188. .fi
  189. .in -0.5i
  190. .sp
  191. Knowledge of the original prepend data is only kept in
  192. the digest.  
  193. Thus one may use the prepend string as a ``salt'' making it intractable 
  194. for someone else to reproduce the digest of a file without knowledge 
  195. of the prepend data.
  196. .sp
  197. This feature works in conjunction all modes of operation except
  198. the \fB\-t\fP and \fB\-x\fP modes.
  199. .TP
  200. .B \-q
  201. Output only digests.
  202. The filename or string will not be written to stdout.
  203. .TP
  204. .BR \-s str
  205. Digest \fIstr\fP as if it were a string.
  206. .sp
  207. The trailing NUL byte is not digested.
  208. No files are digested.
  209. The \fIstr\fP is written to stdout enclosed in double quotes.
  210. .TP
  211. .BR \-t
  212. Time the user cpu seconds needed to digest several megabytes of data.
  213. The number of megabytes,
  214. followed by the digest produced,
  215. followed by the number of user cpu seconds
  216. followed by the number of characters per user second is written to stdout.
  217. .sp
  218. On some systems with certain virtual memory characteristics,
  219. you may need to run the performance test several times, ignoring the
  220. first result.
  221. The default amount of data tested is 16 megabytes.
  222. On some systems, this amount may differ.
  223. One may change the number of megabytes processed by changing the value of
  224. TEST_MEG in the file shsdrvr.c and recompiling.
  225. .TP
  226. .BR \-v
  227. Print the version.
  228. .TP
  229. .BR \-x
  230. Perform an extended standard SHS test suite.
  231. .sp
  232. The test suite will first look in the current directory for
  233. .IR file1 .
  234. If it is not found, it will look in ${DESTDIR} (usually 
  235. .IR /usr/local/lib/shs ).
  236. It is assumes that 
  237. .I file2 
  238. is in the same location as 
  239. .sp
  240. The standard test suite been extended.  
  241. The initial string now says:
  242. .sp
  243. .in +0.5i
  244. .nf
  245. shs test suite results
  246. .fi
  247. .in -0.5i
  248. .sp
  249. instead of:
  250. .sp
  251. .in +0.5i
  252. .nf
  253. SHA test suite results
  254. .fi
  255. .in -0.5i
  256. .sp
  257. to reflect the utility name instead of the algorithm implemented.
  258. This also helps distinguish this version from much older 
  259. versions which did not have the 
  260. .B -v 
  261. flag.
  262. Also the original test file
  263. .I foo
  264. which contained the string  "\fIabc\fP" (with no newline) was renamed 
  265. .IR file1 .
  266. .SH "SEE ALSO"
  267. .BR md5 (1),
  268. .BR stat (2),
  269. .BR lstat (2)
  270. .SH FILES
  271. .nf
  272. \^./file1            default test file location
  273. \^./file2            default test file location
  274. ${DESTDIR}/file1    alternate test file location
  275. ${DESTDIR}/file2    alternate test file location
  276. .fi
  277. .sp
  278. The typical value of ${DESTDIR} is \fI/usr/local/lib/shs\fP,
  279. or \fI/usr/local/lib\fP.
  280. .SH AUTHOR
  281. .nf
  282. Much of this code was written, re-written or modified by:
  283.  
  284.     Landon Curt Noll    (chongo@toad.com)  /\\../\\
  285.  
  286. This code is based on code by Peter C. Gutmann.  Much thanks goes 
  287. to Peter C. Gutman (pgut1@cs.aukuni.ac.nz) , Shawn A. Clifford
  288. (sac@eng.ufl.edu), Pat Myrto (pat@rwing.uucp), Colin Plumb
  289. (colin@nyx10.cs.du.edu), Rich Schroeppel (rcs@cs.arizona.edu)
  290. and others who wrote and/or worked on the original code.
  291. .fi
  292. .SH NOTICE
  293. LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  294. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 
  295. IN NO EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  296. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  297. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  298. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  299. PERFORMANCE OF THIS SOFTWARE.
  300. .SH BUGS
  301. The command:
  302. .sp
  303. .in +0.5i
  304. .nf
  305. shs -s '/\\"O/\\'
  306. .fi
  307. .in -0.5i
  308. .sp
  309. writes to stdout, the following line:
  310. .sp
  311. .in +0.5i
  312. .nf
  313. 013d51217d98b6f2cfa4e7ea13bad8f9bc506f23 "/\\"O/\\"
  314. .fi
  315. .in -0.5i
  316. .sp
  317. The string written in double quotes by
  318. .B \-s
  319. may not be a valid string according to C or shell syntax.
  320.